﻿using ERPEF.Model;
using ERPIService;
using Microsoft.EntityFrameworkCore;
using S4Project;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ERPService
{
    public class pro_warehousingService : pro_warehousingIService
    {
        private readonly MyDbContext myDbContext;
        public pro_warehousingService(MyDbContext myDbContext)
        {
            this.myDbContext = myDbContext;
        }
        //添加
        public async Task<int> Add(pro_warehousing warehousing)
        {
            myDbContext.pro_warehousing.Add(warehousing);
            return await myDbContext.SaveChangesAsync();
        }
        //删除
        public async Task<int> Delete(int pw_id)
        {
            var del = myDbContext.pro_warehousing.Find(pw_id);
            if (del != null)
            {
                del.IsDeleted = true;
                await myDbContext.SaveChangesAsync();
                return 1;
            }
            return 0;
        }
        //查询

        public async Task<List<pro_warehousing>> Query()
        {
            return await myDbContext.pro_warehousing.Where(c => c.IsDeleted == false).ToListAsync();
        }
        //修改
        public async Task<int> Update(pro_warehousing warehousing)
        {
            myDbContext.pro_warehousing.Update(warehousing);
            return await myDbContext.SaveChangesAsync();
        }
    }
}
